import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';

class ThreePageWidget extends StatefulWidget {
  final Map params;
  ThreePageWidget(this.params);
  @override
  _ThreePageWidgetState createState() => _ThreePageWidgetState(params);
}

class _ThreePageWidgetState extends State<ThreePageWidget> {
  final Map params;
  _ThreePageWidgetState(this.params);

  @override
  void initState() {
    super.initState();
    BoostChannel.instance.addEventListener("native_call_flutter", (key, arguments) {
      return handleMsg(key, arguments);
    });
  }

  handleMsg(key, arguments) {
    print("flutter接收到native参数:$key,$arguments");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("threePage"),
        ),
        body: Column(
          children: <Widget>[
            Text("参数是：$params"),
            ElevatedButton(
              onPressed: () {
                BoostNavigator.instance.pop({"key": "返回参数123"});
              },
              child: Text('Go back!'),
            )
          ],
        ));
  }
}
